/*
 * 
 */
package edu.towson.cis.cosc442.project3.vendingmachine;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The unit test Class for VendingMachineItem.
 */
public class VendingMachineItemTest {

	/** Declaring necessary test objects for {@link VendingMachineItem} */
	VendingMachineItem item0;

	/**
	 * Initializes the necessary test objects for the test cases to use.
	 *
	 * @throws Exception
	 *             the exception
	 */
	@Before
	public void setUp() throws Exception {
	}

	/**
	 * Test for the constructor of the {@link VendingMachineItem} class to fail
	 * if an instance is created with a price less than 0
	 */
	@Test(expected = VendingMachineException.class)
	public void testSetUpWithNegative() {
		item0 = new VendingMachineItem("Item 0", -99.0);
		assertNull(item0.getPrice());
	}

	@Test
	public void testSetUp() {
		item0 = new VendingMachineItem("Item 0", 99.0);
		assertNotNull(item0);
	}

	@Test
	public void testItemName() {
		item0 = new VendingMachineItem("Item 0", 99.0);
		assertNotNull(item0);
		assertTrue(item0.getName().equals("Item 0"));
	}

	@Test
	public void testItemPrice() {
		item0 = new VendingMachineItem("Item 0", 99.0);
		assertNotNull(item0);
		assertNotNull(item0.getPrice());
		assertTrue(new Double(item0.getPrice()).equals(new Double(99.0)));
	}

	/**
	 * Cleans up test objects after a test case is executed.
	 */
	@After
	public void tearDown() {
		item0 = null;
	}
}
